home *** CD-ROM | disk | FTP | other *** search
- /************************************************************************
- *
- * Copyright © 1990 Apple Computer, Inc. All rights reserved.
- *
- ************************************************************************/
-
- #include <DialogMgr.h>
- #include <WindowMgr.h>
- #include <fontmgr.h>
- #include <pascal.h>
- #include <stdio.h>
-
- #include "mydialog.h"
- #include "textdlog.h"
- #include "DialogUtils.h"
-
- #define VOLNAME_DIALOG 256
- #define DESTROY_DIALOG 257
- #define FirstButton 1
- #define SecondButton 2
- #define StringField 3
-
- extern void strcpy(char *, char *);
-
-
- /************************************************************************
- *
- * Function: strcpy
- *
- * Purpose: copy a string
- *
- * Returns: nothing
- *
- * Side Effects: copies *src into *dst
- *
- * Description: loop copying until we hit the null byte of src.
- * we assume dst is larger than or equal to src in
- * size, or major damage occurs.
- *
- ************************************************************************/
- static void
- strcpy(dst, src)
- char *dst;
- char *src;
- {
- while (*dst++ = *src++);
- }
-
- /************************************************************************
- *
- * Function: AskForString
- *
- * Purpose: ask the user for a string.
- *
- * Returns: Boolean
- * true if the user entered something
- * false if the user asked to cancel out
- *
- * Side Effects:
- * theString is filled with a C string if we return true.
- *
- * Description:
- * put up a dialog.
- *
- ************************************************************************/
- Boolean
- AskForString(prompt, theString)
- char *prompt;
- char *theString;
- {
- DialogPtr dPtr;
- short result;
- WindowPtr wPtr;
-
- short unusedType; /* for hiliting okay button */
- Handle hItem;
- Rect dBox;
-
- Boolean leaveYet;
-
- Str255 enteredString;
-
- dPtr = GetNewDialog(DU_CenterDLOG(VOLNAME_DIALOG), (DialogPeek)0L, (WindowPtr)-1);
-
- HighLightDefault(dPtr); /* hilite OK button */
-
- SelIText(dPtr, StringField, 0, 999); /* all of the string field selected */
-
- ParamText((StringPtr)prompt, NULL, NULL, NULL);
-
- leaveYet = false;
- do
- {
- HighLightDefault(dPtr);
- ModalDialog(0, &result);
- if (result == FirstButton)
- leaveYet = true;
- if (result == SecondButton)
- {
- SysBeep(1);
- leaveYet = true;
- return false;
- }
- } while (leaveYet == false);
-
-
- GetDItem(dPtr, StringField, &unusedType, &hItem, &dBox);
- GetIText(hItem, (StringPtr)&enteredString);
- strcpy(theString, PtoCstr((char *)&enteredString));
- DisposDialog(dPtr);
- return true;
- }
-
- /************************************************************************
- *
- * Function: AskDestroyDisk
- *
- * Purpose: Check that you really want to nuke a disk
- *
- * Returns: Boolean
- * true = yes, destroy it
- * false = no, leave it alone, it was a mistake.
- *
- * Side Effects: none.
- *
- * Description: display our warning about destroying a disk.
- * Ask, using a modal dialog, whether the user really
- * wants to lose it. (Default button is cancel, since
- * this is such a permanent thing...)
- *
- *
- ************************************************************************/
- Boolean
- AskDestroyDisk(driveNumber)
- short driveNumber;
- {
- DialogPtr dPtr;
- short result;
- short unusedType; /* for hiliting okay button */
- Boolean leaveYet;
- Boolean okayToDestroy;
-
- Str255 volumeName;
- short vRefNum;
- long freeBytes;
-
- okayToDestroy = true;
- dPtr = GetNewDialog(DU_CenterDLOG(DESTROY_DIALOG), (DialogPeek)0L, (WindowPtr)-1);
-
- HighLightDefault(dPtr);
-
- if (GetVInfo(driveNumber, volumeName, &vRefNum, &freeBytes) != noErr)
- okayToDestroy = false;
-
- if (okayToDestroy)
- {
- ParamText((StringPtr)volumeName, NULL, NULL, NULL);
-
- leaveYet = false;
- do
- {
- HighLightDefault(dPtr);
- ModalDialog(0, &result);
- if (result == SecondButton)
- leaveYet = true;
- if (result == FirstButton)
- {
- SysBeep(1);
- leaveYet = true;
- okayToDestroy = false;
- }
- } while (leaveYet == false);
- }
-
- DisposDialog(dPtr);
- return okayToDestroy;
- }
-
-
-
- /************************************************************************
- *
- * Function: Help
- *
- * Purpose: explain what we're doing
- *
- * Returns: void
- *
- * Side Effects: none.
- *
- * Description: display our help text. Currently always returns true.
- *
- *
- ************************************************************************/
- Boolean
- Help()
- {
- Handle tHandle;
-
- tHandle = GetResource('TEXT', 1001);
- if (tHandle != (Handle)0)
- {
- HLock(tHandle);
- TextDialog(1001, tHandle, times, 12, true);
- HUnlock(tHandle);
- ReleaseResource(tHandle);
- }
- return true;
- }
-
-